﻿<Page
    x:Name="pageRoot"
    x:Class="BootyBay.PrivateStoreApp.YourAppsPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BootyBay.PrivateStoreApp"
    xmlns:common="using:BootyBay.PrivateStoreApp.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.TopAppBar>
        <AppBar BorderThickness="1" BorderBrush="#99205B96" Margin="0,-2,0,0">
            <Grid Height="105" Background="#99205B96">
                <StackPanel Orientation="Horizontal">
                    <Button Margin="27,0,0,0" Content="主页" Background="#77ACE1" BorderThickness="0" Style="{StaticResource AppsPage_Home_ButtonStyle}" x:Name="btn_Home" Click="btn_Home_Click"></Button>
                    <Button Margin="10,0,0,0" Content="你的应用" Background="#77ACE1" BorderThickness="0" Style="{StaticResource AppsPage_YourApps_ButtonStyle}" x:Name="btn_AppList" Click="btn_AppList_Click"></Button>


                </StackPanel>
                <!--temporarily added by Ranger-->
                <TextBlock Grid.Column="4" Margin="0,0,20,0" VerticalAlignment="Center" HorizontalAlignment="Right" x:Name="txt_UserName" Text="Display Name" Foreground="White" Style="{StaticResource AppListPage_descriptionInfo2_TextStyle}"></TextBlock>
            </Grid>
        </AppBar>
    </Page.TopAppBar>
    <Page.Resources>
        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">你的应用</x:String>
        <!--<common:ApplicationStatusConverter x:Key="ApplicationStatusConverter"></common:ApplicationStatusConverter>-->
        <common:IsShowDefaultPicConverter x:Key="IsShowDefaultPicConverter"></common:IsShowDefaultPicConverter>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid>
        <Grid.Background>
            <ImageBrush ImageSource="Images/bg.png"></ImageBrush>
        </Grid.Background>
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="95"/>
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Margin="39,45,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Top"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
            <TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Top" Margin="0,45,30,0"/>
            <TextBlock x:Name="txt_AppNumber" Grid.Column="2" Margin="0,45,0,0" VerticalAlignment="Top" Text="0" Style="{StaticResource AppListPage_descriptionInfo_TextStyle}"></TextBlock>
            <TextBlock Grid.Column="3" Margin="0,45,0,0" VerticalAlignment="Top" Text="个应用" Style="{StaticResource AppListPage_descriptionInfo_TextStyle}"></TextBlock>

        </Grid>
        <GridView x:Name="itemGridView" Grid.Row="1" IsItemClickEnabled="True" SelectionMode="Multiple" Padding="120,0,0,40" 
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  ItemClick="itemGridView_ItemClick"
                  SelectionChanged="itemGridView_SelectionChanged"
                  ItemContainerStyle="{StaticResource YourAppsPage_AppListItemStyle}"
                  >
            <GridView.ItemTemplate>
                <DataTemplate>
                    <Grid Width="311">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Border Grid.RowSpan="3" Grid.Column="0" Background="#92BCE7" Height="70" Width="70">
                            <Image Width="50" Height="50" Source="{Binding AppView.LogoUrl_Store,Converter={StaticResource IsShowDefaultPicConverter},ConverterParameter=/Images/default_50_50.png}"></Image>
                        </Border>
                        <TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding AppView.ApplicationName}" Style="{StaticResource AppListPage_descriptionInfo2_TextStyle}"></TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="2" Style="{StaticResource AppListPage_descriptionInfo3_TextStyle}">
                            <Run Text="已购买 "></Run>
                            <Run Text="{Binding AppView.CreationDate}"></Run>
                        </TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding LocalStatus}" Style="{StaticResource AppListPage_descriptionInfo4_TextStyle}"></TextBlock>
                    </Grid>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>
        <Grid Grid.Row="2" Margin="38,0,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="60"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <ToggleButton Grid.Column="0" x:Name="btn_SelectAll" Click="btn_SelectAll_Click" Content="全选" VerticalAlignment="Top" Style="{StaticResource AppListPage_selectall_ButtonStyle}"></ToggleButton>
            <Grid Grid.Column="2" x:Name="grd_Panel" Visibility="Collapsed">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="60"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="60"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Button Grid.Column="2" x:Name="btn_UnInstall" Click="btn_UnInstall_Click" Content="卸载" VerticalAlignment="Top" Style="{StaticResource AppListPage_clearall_ButtonStyle}"></Button>
                <Border Grid.Column="0" BorderThickness="1,0,0,0" Height="35" VerticalAlignment="Top" BorderBrush="#000000"></Border>
                <Button Grid.Column="4" x:Name="btn_Install" Visibility="Collapsed" Click="btn_Install_Click" Command="{Binding RequestInstallationCommand}" Content="安装" VerticalAlignment="Top" Style="{StaticResource AppListPage_install_ButtonStyle}"></Button>
            </Grid>

        </Grid>
    </Grid>
</Page>
